package main.mvc.utils;

public class BuildHelper {
	
	/** PropertiesParse */
	public static PropertiesParse getPropertiesparse(){
		return new PropertiesParse(Constants.migrateFilePath);
	}
	
	/** entityName */
	public static String buildEntityName(String tableName, Boolean isClass){
		StringBuffer entityName = new StringBuffer();
		String entityNames[] = tableName.split("_");
		for(int i=0; i<entityNames.length; i++){
			String s = entityNames[i];
			if(i == 0){
				if(isClass){
					entityName.append(s.substring(0, 1).toUpperCase()+s.substring(1, s.length()));
				} else {
					entityName.append(s);
				}
			} else {
				entityName.append(s.substring(0, 1).toUpperCase()+s.substring(1, s.length()));
			}
		}
		return entityName.toString();
	}
	
	/** \n\t */
	public static String getNAndT(Integer n, Integer t){
		StringBuffer s = new StringBuffer();
		for(int i=0; i<n ; i++){
			s.append("\n");
		}
		for(int i=0; i<t; i++){
			s.append("\t");
		}
		return s.toString();
	}
	
	/** import */
	public static String getImport(Integer type){
		String result = "";
		switch (type) {
		case 1:
			result = "import java.util.List;";
			break;
		case 2:
			result = "import com.spring.exception.DaoException;";
			break;
		case 3:
			result = "import com.spring.exception.ServiceException;";
			break;
		case 4:
			result = "import com.spring.exception.ActionException;";
			break;
		case 5:
			result = "import com.spring.service.ServiceSupport;";
			break;
		case 6: // entity
			result = "import " + getPropertiesparse().getValue("bean.build.entity.package") + ".";
			break;
		case 7: // form
			result = "import " + getPropertiesparse().getValue("bean.build.form.package") + ".";
			break;
		case 8: // dao
			result = "import " + getPropertiesparse().getValue("dao.build.package") + ".";
			break;
		case 9: // service
			result = "import " + getPropertiesparse().getValue("service.build.package") + ".";
			break;
		case 10: // action
			result = "import " + getPropertiesparse().getValue("action.build.package") + ".";
			break;
		case 11:
			result = "import org.springframework.beans.factory.annotation.Autowired;"; 
			break;
		case 12:
			result = "import org.springframework.jdbc.core.JdbcTemplate;";
			break;
		case 13:
			result = "import org.springframework.stereotype.Repository;";
			break;
		case 14:
			result = "import com.spring.dao.DaoSupport;";
			break;
		case 15:
			result = "import com.spring.bean.page.Page;";
			break;
		case 16:
			result = "import com.spring.bean.page.PageView;";
			break;
		case 17:
			result = "import org.springframework.stereotype.Service;";
			break;
		case 18:
			result = "import org.springframework.transaction.annotation.Transactional;";
			break;
		}
		
		return result;
	}
}
